﻿// use_2_rzbl.cpp: 实现文件
//

#include "pch.h"
#include "HoManSys1.h"
#include "use_2_rzbl.h"
#include "afxdialogex.h"
#include "ADOconnection.h"

// use_2_rzbl 对话框
ADOconnection cond;
IMPLEMENT_DYNAMIC(use_2_rzbl, CDialogEx)

use_2_rzbl::use_2_rzbl(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG_rzbl, pParent)
	, m_ddbh(_T(""))
	, m_droom(_T(""))
	, m_cuname(_T(""))
	, m_tem(_T(""))
	, m_idcard(_T(""))
	, m_phone(_T(""))
{

}

use_2_rzbl::~use_2_rzbl()
{
}

void use_2_rzbl::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT1, m_ddbh);
	DDX_Text(pDX, IDC_EDIT2, m_droom);
	DDX_Text(pDX, IDC_EDIT3, m_cuname);
	DDX_Text(pDX, IDC_EDIT5, m_tem);
	DDX_Text(pDX, IDC_EDIT4, m_idcard);
	DDX_Text(pDX, IDC_EDIT6, m_phone);
}


BEGIN_MESSAGE_MAP(use_2_rzbl, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON1, &use_2_rzbl::OnBnClickedButton1)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDOK, &use_2_rzbl::OnBnClickedOk)
END_MESSAGE_MAP()


// use_2_rzbl 消息处理程序


void use_2_rzbl::OnBnClickedButton1()
{
	// TODO: 在此添加控件通知处理程序代码
	
	
	

	
}


BOOL use_2_rzbl::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// TODO:  在此添加额外的初始化
	SetTimer(1, 1000, NULL);
	SetDlgItemText(IDC_STATIC_czy, global_msg);
	
	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}


void use_2_rzbl::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	CString strTime;
	CTime tm;
	tm = CTime::GetCurrentTime();
	strTime = tm.Format("%Y-%m-%d %H:%M:%S");
	SetDlgItemText(IDC_time, strTime);        //显示系统时间
	CDialogEx::OnTimer(nIDEvent);
}


void use_2_rzbl::OnBnClickedOk()
{
	// TODO: 在此添加控件通知处理程序代码

	GetDlgItemText(IDC_STATIC_czy, global_msg);

	{if (IsDlgButtonChecked(IDC_CHECK1))
		s_sex = _T("女");
	if (IsDlgButtonChecked(IDC_CHECK2))
		s_sex = _T("男");
	}

	{if (IsDlgButtonChecked(IDC_RADIO3))
		s_code = _T("红");
	if (IsDlgButtonChecked(IDC_RADIO4))
		s_code = _T("绿");
	}
	UpdateData();
	ADOconnection   conn;
	conn.DBConnection();
	m_pTr.CreateInstance(__uuidof(Recordset));
	m_pTr->Open(_bstr_t(_T("select * from ord")), conn.m_pCon.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText);
	

	
	m_pTr->AddNew();
	
	/*m_pTr->PutCollect(_variant_t(_T("sno")), _variant_t(m_sno));
	m_pTr->PutCollect(_variant_t(_T("sname")), _variant_t(m_sname));
	m_pTr->PutCollect(_variant_t(_T("sage")), _variant_t((int)m_sage));
	m_pTr->Update();
	MessageBox(_T("当前记录已插入！")); */
	
	
	m_pTr->PutCollect(_variant_t(_T("orderID")), _variant_t(m_ddbh));
	m_pTr->PutCollect(_variant_t(_T("staffID")), _variant_t(global_msg));
	m_pTr->PutCollect(_variant_t(_T("roomID")), _variant_t(m_droom));
	m_pTr->PutCollect(_variant_t(_T("cname")), _variant_t(m_cuname));
	m_pTr->PutCollect(_variant_t(_T("csex")), _variant_t(s_sex));
	m_pTr->PutCollect(_variant_t(_T("cID")), _variant_t(m_idcard));
	m_pTr->PutCollect(_variant_t(_T("cphone")), _variant_t(m_phone));
	m_pTr->PutCollect(_variant_t(_T("hecode")), _variant_t(s_code));
	m_pTr->PutCollect(_variant_t(_T("tem")), _variant_t(m_tem));
	m_pTr->Update();
	m_pTr->Close();
	MessageBox(_T("入住办理成功！"));
	CDialogEx::OnOK();
}
